import request from '../utils/request'

const articleDetails = (a) => request({
  url: '/v1_0/articles/' + a
})
// 关注
const followed = (a) => request({
  method: 'POST',
  url: '/v1_0/user/followings',
  data: {
    target: a
  }
})
const noFollowed = (a) => request({
  method: 'DELETE',
  url: '/v1_0/user/followings/' + a
})
// 点赞
const collected = (a) => request({
  method: 'POST',
  url: '/v1_0/article/likings',
  data: {
    target: a
  }
})
const noCollected = (a) => request({
  method: 'DELETE',
  url: '/v1_0/article/likings/' + a,
  data: {
    target: a
  }
})
const getComment = ({ source, offset, limit }) => request({
  url: '/v1_0/comments',
  params: {
    type: 'a',
    source,
    offset,
    limit
  }
})
// 发布评论
const setComment = (target, content) => request({
  method: 'POST',
  url: '/v1_0/comments',
  data: {
    target,
    content
  }
})
// 评论喜欢
const setLike = (target) => request({
  method: 'POST',
  url: '/v1_0/comment/likings',
  data: {
    target
  }
})
const disLike = (id) => request({
  method: 'DELETE',
  url: '/v1_0/comment/likings/' + id
})

export { articleDetails, followed, noFollowed, collected, noCollected, getComment, setComment, setLike, disLike }
